widget-factory: Don't leak GPropertyAction instances
authorTimm Bäder <mail@baedert.org>
Fri, 6 Oct 2017 14:30:20 +0000 (16:30 +0200)
committerTimm Bäder <mail@baedert.org>
Fri, 6 Oct 2017 14:30:20 +0000 (16:30 +0200)
demos/widget-factory/widget-factory.c

index 8d14034d0ba62914209915710590f44e11922f54..5c80cab635b82a02054f1daaa3cf6d2898c352d9 100644 (file)
@@ -1695,12 +1695,14 @@ activate (GApplication *app)
 
   widget = (GtkWidget *)gtk_builder_get_object (builder, "statusbar");
   gtk_statusbar_push (GTK_STATUSBAR (widget), 0, "All systems are operating normally.");
-  g_action_map_add_action (G_ACTION_MAP (window),
-                           G_ACTION (g_property_action_new ("statusbar", widget, "visible")));
+  action = G_ACTION (g_property_action_new ("statusbar", widget, "visible"));
+  g_action_map_add_action (G_ACTION_MAP (window), action);
+  g_object_unref (G_OBJECT (action));
 
   widget = (GtkWidget *)gtk_builder_get_object (builder, "toolbar");
-  g_action_map_add_action (G_ACTION_MAP (window),
-                           G_ACTION (g_property_action_new ("toolbar", widget, "visible")));
+  action = G_ACTION (g_property_action_new ("toolbar", widget, "visible"));
+  g_action_map_add_action (G_ACTION_MAP (window), action);
+  g_object_unref (G_OBJECT (action));
 
   adj = (GtkAdjustment *)gtk_builder_get_object (builder, "adjustment1");